﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;
using EntityModule;

namespace Sport
{
    public partial class ThemeSetting : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["mode"] == "changeTheme")
            {
                string fbid = Session[Constant.UserID].AsString();
                User user = Service.Users.FirstOrDefault(s => s.FBID == fbid);
                string style = Request.QueryString["style"].AsString();
                string theme = string.Empty;
                theme += "background-image:" + style.Split('_')[0].Replace("XX", "/").Replace("BB", "(").Replace("CC", ")")+";";
                theme += "background-color:" + style.Split('_')[1].Replace("AA", ",") + ";";
                theme += "background-repeat:" + style.Split('_')[2] + ";";
                theme += "background-attachment:" + style.Split('_')[3] + ";";
                Session[Constant.StyleTheme] = theme;
                if (user != null && theme.IsNotNullOrEmpty())
                {
                    Session[Constant.StyleTheme] = user.StypeTheme = theme;
                    Service.SubmitChanges();
                }
            }
        }
    }
}
